package com.zoranjoka.chordis.pages;

import java.io.Serializable;

import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.zoranjoka.chordis.Artist;
import com.zoranjoka.chordis.beans.ArtistBean;
import com.zoranjoka.chordis.hibernate.IDataArtistService;

public class AddArtist {
	
	@Component(id="addArtistForm")
	private Form form;
	
	@Persist("flash")
	private String name;
	
	private Serializable id;
	
	@Inject
	private IDataArtistService artistService;
	
	private Artist artist;
	
	@InjectPage
	private AddArtist page;
	
	Serializable onPassivate(){
        return id;
    }
	
	void onSuccessFromAddRoomForm(){
        System.out.println("Handling form submission!");
        artist = new ArtistBean();
        artist.setArtistName(name);
        artistService.addArtistBean(artist);
       page.setName("Artist " + getName() + " is successfuly added!");
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setId(Serializable id) {
		this.id = id;
	}
	
}
	


